<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <!--[if lt IE 9]>
  <script type="text/javascript" src="lib/html5.js"></script>
  <script type="text/javascript" src="lib/respond.min.js"></script>
  <![endif]-->
  <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
  <link rel="stylesheet" type="text/css" href="static/h-ui.admin.pro/css/H-ui.login.min.css" />
  <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.9/iconfont.css" />
  <link rel="stylesheet" type="text/css" href="static/business/css/style.css" />
  <!--[if IE 6]>
  <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
  <script>DD_belatedPNG.fix('*');</script><![endif]-->
  <title>后台登录 - h-ui.admin.pro v1.0</title>
  <meta name="keywords" content="h-ui.admin.pro v1.0,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
  <meta name="description" content="h-ui.admin.pro v1.0，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
  <input type="hidden" id="TenantId" name="TenantId" value="" />
  <div class="header"></div>
  <div class="loginWraper">
    <div class="loginBox">
      <form id="form-admin-login" class="form form-horizontal">
        <div class="row clearfix">
          <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
          <div class="form-controls col-xs-7">
            <input id="studentName" name="studentName" type="text" placeholder="账户" class="input-text size-L">
          </div>
        </div>
        <div class="row clearfix">
          <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
          <div class="form-controls col-xs-7">
            <input id="password" name="password" type="password" placeholder="密码" class="input-text size-L">
          </div>
        </div>
        <div class="row clearfix">
          <div class="form-controls col-xs-7 col-xs-offset-3">
            <select id="identity" style="width: 150px;height: 40px;font-size: 13px;color: gray;">
              <option value="0">管理员</option>
              <option value="1">学员</option>
            </select>
            <a id="kanbuq" href="javascript:;">请选择身份</a>
          </div>
        </div>
        <div class="row clearfix">
          <div class="form-controls col-xs-7 col-xs-offset-3">
            <label for="online">
              <input type="checkbox" name="online" id="online" value="">
          使我保持登录状态
            </label>
          </div>
        </div>
        <div class="row clearfix">
          <div class="form-controls col-xs-8 col-xs-offset-3">
            <input id="loginBtn" type="button" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
            <input name="" type="reset" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
          </div>
        </div>
        <div style="text-align: right; margin-right: 50px;display: none" id="forgot"><a href="forgetPage.html">忘记密码</a></div>
      </form>
    </div>
  </div>
  <div class="footer">Copyright 你的公司名称 by h-ui.admin.pro.iframe v1.0</div>

  <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
  <script type="text/javascript" src="static/h-ui/js/H-ui.js"></script>
  <script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
  <script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
  <script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
  <script type="text/javascript">
    $(function () {
      $("#identity").change(function () {
        var identity = $("#identity").val();
        //console.log(identity);
         if (identity == 0){
           $("#forgot").hide();
         }else {
           // 让忘记密码连接显示出来
           $("#forgot").css("display", "");
         }
      })

      $("#loginBtn").click(function () {
        // 获取用户类型，判断是管理员还是学员
        var identity = $("#identity").val();
        //获取用户名和密码，并构建json对象
        var data = {"studentName":$("#studentName").val(),
          "password":$("#password").val()
        };
        var url;
        if(identity == 0){
          url = "managerInfo?action=login"
        }else if(identity == 1){
          url = "student?action=login";
        }
        $.ajax({
          method:"post",
          url:url,
          data:data,
          type:"json",
          success:function (result){
            console.log(result);
            if (result.code == 20001){
              alert(result.msg);
              // 传入身份信息，确定页面显示内容，如果没有该参数，就跳转回登录界面
              if(identity == 1) {
                location.href = "index.html";
              }else if(identity == 0){
                location.href="dormitory-statistical.html";
              }
            }else{
              alert(result.msg);
            }
          }
        });
      })
    })
  </script>
</body>
</html>
